//
//  HomeCollectionCell.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/14.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "HomeCollectionCell.h"

@interface HomeCollectionCell ()
@property (weak, nonatomic) IBOutlet UIImageView *topImageView;
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *bottomLabel;
@property (weak, nonatomic) IBOutlet UIButton *jumpBtn;
@property (weak, nonatomic) IBOutlet UIView *progressView;
@property (weak, nonatomic) IBOutlet UIView *progressTopView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *progressW;


@end

@implementation HomeCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.topLabel.font = SubTitleFont;
    self.bottomLabel.font = DetailFont;

    
    self.progressView.backgroundColor = lineGray;
    self.progressTopView.backgroundColor = themeColor;
    
    
    self.progressView.layer.cornerRadius = 3;
    self.progressView.layer.masksToBounds = YES;
    
  
    
    self.jumpBtn.layer.cornerRadius = 5;
    self.jumpBtn.layer.masksToBounds = YES;
    self.jumpBtn.layer.borderColor = themeColor.CGColor;
    self.jumpBtn.layer.borderWidth = 0.6;
    self.jumpBtn.backgroundColor = [UIColor whiteColor];
    [self.jumpBtn setTitleColor:themeColor forState:UIControlStateNormal];
    [self.jumpBtn setTitleColor:themeColor forState:UIControlStateHighlighted];
    
    self.jumpBtn.titleLabel.font = BigTitleFont;
    
    
    
    // Initialization code
}


- (void)setModel:(GoodsInfoModel *)model{
    _model = model;
    
    [self.topImageView sd_setImageWithURL:[NSURL URLWithString:_model.goods_image]];
    
    self.topLabel.text = _model.goods_name;
    
    
    self.bottomLabel.attributedText = [self attributedString];
    
   
    self.progressW.constant = ((KScreenW - 2) * 0.5 - 98)/100.0 * _model.percent.floatValue;
    
    
}



- (NSMutableAttributedString *)attributedString{
    //    [NSString stringWithFormat:@"主营业务: %@",_model.desc];
    
    NSMutableAttributedString *attributeString6 = [[NSMutableAttributedString alloc] init];
    NSAttributedString *string26 = [[NSAttributedString alloc] initWithString:@"剩余:" attributes:@{NSFontAttributeName :DetailFont ,NSForegroundColorAttributeName : darkGray}];
    
    
    NSAttributedString *string27 = [[NSAttributedString alloc] initWithString:self.model.remain_count attributes:@{NSFontAttributeName : DetailFont,NSForegroundColorAttributeName : themeColor}];
    
    
    NSAttributedString *string29 = [[NSAttributedString alloc] initWithString:@"次" attributes:@{NSFontAttributeName :DetailFont ,NSForegroundColorAttributeName : darkGray}];
    
    
    
    //    NSMutableParagraphStyle *para = [[NSMutableParagraphStyle alloc]init];
    //
    //    para.lineSpacing = 3;
    
    [attributeString6 appendAttributedString:string26];
    [attributeString6 appendAttributedString:string27];
    [attributeString6 appendAttributedString:string29];
    
    //    [attributeString6 addAttribute:NSParagraphStyleAttributeName value:para range:NSMakeRange(0, attributeString6.length)];
    
    return attributeString6;
    
    
}

@end
